/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entityprojet;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author T.Ron
 */
@Entity
@Table(name = "JOPERIODE")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Joperiode.findAll", query = "SELECT j FROM Joperiode j"),
    @NamedQuery(name = "Joperiode.findByIdJop", query = "SELECT j FROM Joperiode j WHERE j.idJop = :idJop"),
    @NamedQuery(name = "Joperiode.findByCloture", query = "SELECT j FROM Joperiode j WHERE j.cloture = :cloture")})
public class Joperiode implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID_JOP")
    private Integer idJop;
    @Column(name = "CLOTURE")
    private Short cloture;
    @OneToMany(mappedBy = "idJop")
    private Collection<Ecriturec> ecriturecCollection;
    @JoinColumns({
        @JoinColumn(name = "NUMEXO", referencedColumnName = "NUMEXO"),
        @JoinColumn(name = "MOIS", referencedColumnName = "MOIS")})
    @ManyToOne(optional = false)
    private Periode periode;
    @JoinColumn(name = "NUMJO", referencedColumnName = "NUMJO")
    @ManyToOne(optional = false)
    private Journaux numjo;

    public Joperiode() {
    }

    public Joperiode(Integer idJop) {
        this.idJop = idJop;
    }

    public Integer getIdJop() {
        return idJop;
    }

    public void setIdJop(Integer idJop) {
        this.idJop = idJop;
    }

    public Short getCloture() {
        return cloture;
    }

    public void setCloture(Short cloture) {
        this.cloture = cloture;
    }

    @XmlTransient
    public Collection<Ecriturec> getEcriturecCollection() {
        return ecriturecCollection;
    }

    public void setEcriturecCollection(Collection<Ecriturec> ecriturecCollection) {
        this.ecriturecCollection = ecriturecCollection;
    }

    public Periode getPeriode() {
        return periode;
    }

    public void setPeriode(Periode periode) {
        this.periode = periode;
    }

    public Journaux getNumjo() {
        return numjo;
    }

    public void setNumjo(Journaux numjo) {
        this.numjo = numjo;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idJop != null ? idJop.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Joperiode)) {
            return false;
        }
        Joperiode other = (Joperiode) object;
        if ((this.idJop == null && other.idJop != null) || (this.idJop != null && !this.idJop.equals(other.idJop))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entityprojet.Joperiode[ idJop=" + idJop + " ]";
    }
    
}
